package com.hjm.suanfa.美团;

import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;

public class 数组询问 {
    //https://www.nowcoder.com/exam/test/88247074/detail?pid=55750560&examPageSource=Company&subTabName=written_page&testCallback=https%3A%2F%2Fwww.nowcoder.com%2Fexam%2Fcompany%3FquestionJobId%3D10%26subTabName%3Dwritten_page&testclass=%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91
    // 测试数据过大时会导致 超时
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        int sum = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a == 0) {
                count++;
            }
            sum += a;
        }

        for (int i = 0; i < q; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println((sum + (a * count)) + " " + (sum + (b * count)));
        }
    }

    // 使用 bufferedReader以及 printWriter和StringBuilder 进行输入输出
/*    public static void main(String[] args) throws IOException {
        // 1. FAST IO 初始化
        BufferedReader  in  = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter     out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        StringTokenizer st  = new StringTokenizer(in.readLine(), " ");

        // 2. 读入 n, q
        int n = Integer.parseInt(st.nextToken());
        int q = Integer.parseInt(st.nextToken());

        long sum = 0;
        long count = 0;

        // 3. 读入原数组并统计 sum、0 的个数
        st = new StringTokenizer(in.readLine(), " ");
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(st.nextToken());
            sum += a;
            if (a == 0) count++;
        }

        // 4. 处理 q 次查询
        //    每次都只做 O(1) 计算，用 StringBuilder 累积输出
        StringBuilder sb = new StringBuilder(q * 20);
        for (int i = 0; i < q; i++) {
            st = new StringTokenizer(in.readLine(), " ");
            long a = Long.parseLong(st.nextToken());
            long b = Long.parseLong(st.nextToken());
            long min = sum + a * count;
            long max = sum + b * count;
            sb.append(min).append(' ').append(max).append('\n');
        }

        // 5. 一次性写出
        out.print(sb);
        out.flush();
    }*/
}
